#include "Vector3F.h"


Vector3F::Vector3F()
:X(0), Y(0), Z(0)
{}

Vector3F::Vector3F(float x,float y,float z)
:X(x), Y(y), Z(z)
{}


Vector3F::Vector3F(const Vector3F & v)
{
	X = v.X;
	Y = v.Y;
	Z = v.Z;
}

Vector3F::Vector3F(const Vector3F & from,const Vector3F & to)
{
	X = to.X - from.X;
    Y = to.Y - from.Y;
    Z = to.Z - from.Z;
}

Vector3F & Vector3F::operator= (const Vector3F & v)
{
	X = v.X;
	Y = v.Y;
	Z = v.Z;
	return *this;
}

Vector3F & Vector3F::operator+= (const Vector3F & v)
{
	X += v.X;
	Y += v.Y;
	Z += v.Z;
	return *this;
}

Vector3F Vector3F::operator+ (const Vector3F & v)
{
	Vector3F t;
	t.X = v.X + X;
	t.Y = v.Y + Y;
	t.Z = v.Z + Z;
	return t;	
}

Vector3F & Vector3F::operator-= (const Vector3F & v)
{
	X -= v.X;
	Y -= v.Y;
	Z -= v.Z;
	return *this;
}

Vector3F Vector3F::operator- (const Vector3F & v)
{
	Vector3F t;
	t.X = X - v.X;
	t.Y = Y - v.Y;
	t.Z = Z - v.Z;
	return t;	
}

Vector3F & Vector3F::operator*= (const float a)
{
	X *= a;
	Y *= a;
	Z *= a;
	return *this;
}

Vector3F Vector3F::operator* (const float a)
{
	Vector3F t;
	t.X = X * a;
	t.Y = Y * a;
	t.Z = Z * a;
	return t;
}

Vector3F operator* (const float a,const Vector3F & v)
{
	return Vector3F(v.X*a, v.Y*a, v.Z*a);
}

Vector3F & Vector3F::operator/= (const float a)
{
	X /= a;
	Y /= a;
	Z /= a;
	return *this;
}

Vector3F Vector3F::operator/ (const float a)
{
	Vector3F t;
	t.X = X / a;
	t.Y = Y / a;
	t.Z = Z / a;
	return t;
}

Vector3F Vector3F::crossProduct(const Vector3F & v) const
{
	Vector3F t;
	t.X = (Y*v.Z)-(Z*v.Y);
	t.Y = (Z*v.X)-(X*v.Z);
	t.Z = (X*v.Y)-(Y*v.X);
	return t;
}

float Vector3F::length()const
{
	return sqrt( X*X + Y*Y + Z*Z);
}

Vector3F & Vector3F::normalize()
{
	(*this) /= length();
    return (*this);
}

